package io.finer.erp.jeecg.stock.mapper;

import java.util.List;

import io.finer.erp.jeecg.finance.dto.CustomerGrossDetailDTO;
import io.finer.erp.jeecg.finance.dto.CustomerGrossProfitDTO;
import io.finer.erp.jeecg.finance.dto.GrossProfitDetailDTO;
import io.finer.erp.jeecg.finance.dto.GrossProfitSummaryDTO;
import io.finer.erp.jeecg.stock.dto.StkIoBillEntryDTO;
import io.finer.erp.jeecg.stock.entity.StkIoBillEntry;
import io.finer.erp.jeecg.stock.vo.StkIoBillVO;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @Description: 明细
 * @Author: jeecg-boot
 * @Date:   2020-03-31
 * @Version: V1.0
 */
public interface StkIoBillEntryMapper extends BaseMapper<StkIoBillEntry> {

	public boolean deleteByMainId(@Param("mainId") String mainId);
    
	public List<StkIoBillEntry> selectByMainId(@Param("mainId") String mainId);

	@Select("select entry.* from stk_io_bill_entry entry LEFT JOIN stk_io_bill bill ON entry.mid=bill.id where bill.stock_io_type='101' and bill.source_type='purchase_order' and bill.source_no=#{orderNum} AND bill.is_closed=0")
	public List<StkIoBillEntry> getPurchaseOrderEntry(String orderNum);

	@Select("select * from stk_io_bill_entry entry where entry.mid in (select id from stk_io_bill where source_no=#{purchaseNo})")
	public List<StkIoBillEntry> selectByPurchase(@Param("purchaseNo")String purchaseNo);
	
	public List<StkIoBillEntry> selectBatchByMainIdList(@Param("mainIdList") List<String> mainIdList);
	
	public List<GrossProfitSummaryDTO> selectBillEntry(@Param("vo") StkIoBillVO vo);
	
	public List<GrossProfitDetailDTO> selectGrossProfitDetail(@Param("vo") StkIoBillVO vo);
	
	public List<CustomerGrossProfitDTO> selectCustomerGrossProfit(@Param("vo") StkIoBillVO vo);
	
	public List<CustomerGrossDetailDTO> selectCustomerGrossProfitDetail(@Param("vo") StkIoBillVO vo);
	
	public IPage<StkIoBillEntryDTO> selectEntryBySupplier(IPage<StkIoBillEntryDTO> page, @Param("vo") StkIoBillVO vo);
}
